package com.pdsu.xpf.graduation01.control;

import com.pdsu.xpf.graduation01.domain.Admin;
import com.pdsu.xpf.graduation01.service.impl.UserServiceImpl;
import com.pdsu.xpf.graduation01.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class AdminController {

    final
    UserServiceImpl userService;

    public AdminController(UserServiceImpl userService) {
        this.userService = userService;
    }

    @ResponseBody
    @RequestMapping("/login")
    public Result login(String username,String password){


        List<Admin> admins=userService.adminLogin(username,password);
        if (admins.size()>0){
            return Result.success();
        }

        return Result.failed();
    }
}
